<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>css颜色过度</title>
</head>
<body>
<style>

</style>
<div id="testcolor" style="width: 100px;height: 100px; background: red; transition: 1s; "></div>
</body>
<script>

    window.onload = function () {
        document.querySelector('#testcolor').style.background = 'yellow';
    }

</script>
</html>